package com.he.algorithm.stack;

import java.util.Stack;

/**
 * @description: TODO
 * @Author: HCL
 * @Date: 2024/9/11 9:20
 */
public class StackUtil {

    static Stack<Integer> inStack = new Stack<>();
    static Stack<Integer> outStack = new Stack<>();

    public static void push(int data){
       inStack.push(data);
    }

    public static int pop(){
       //保证工具栈是空的，然后将输入栈的元素出栈并压入工具栈
        if (outStack.isEmpty()){
            while (!inStack.isEmpty()){
                outStack.push(inStack.pop());
            }
        }
        return outStack.pop();
    }

    public static void main(String[] args) {
        push(1);
        push(2);
        push(3);
        push(4);
        System.out.println(pop());
        System.out.println(pop());
    }
}
